<?php
// 伪原创工具 aming
	class regular{
		
		function __construct()
		{
			
		}
	
		function regular()
		{
			$this->__construct();
		}
		
		function original($str){
			return $this->htmltrim($str);
		}
		
		// 针对采集文章的大部分标签行进过滤，需要新添加的话在下面修改即可
		function htmltrim($content){
			$pregs = array(
		
				"/<a[^>]*?>([\w\W]*?)<\/a>/i" => "$1",
				"/<table[^>]*?>([\w\W]*?)<\/table>/i" => "<p>$1</p>",
				"/<tr[^>]*?>([\w\W]*?)<\/tr>/i" => "<p>$1</p>",
				"/<td[^>]*?>([\w\W]*?)<\/td>/i" => "$1",
				"/<p[^>]*?>([\w\W]*?)<\/p>/i" => "<p>$1</p>",
				"/<font[^>]*?>([\w\W]*?)<\/font>/i" => "$1",
				"/<div[^>]*?>([\w\W]*?)<\/div>/i" => "<p>$1</p>",
				"/<span[^>]*?>([\w\W]*?)<\/span>/i" => "$1",
				"/<([\/]?)b>/i" => "",
				"/<tbody[^>]*?>([\w\W]*?)<\/tbody>/i" => "$1",
				/*"/<img[^>]*?>/i" => "",*/
				/*"/[&nbsp;]{2,}/i" => "&nbsp;",*/
				"/<script[^>]*?>([\w\W]*?)<\/script>/i" => "",
				
				// +++++ 后来补充
				"/<strong[^>]*?>([\w\W]*?)<\/strong>/i" => "$1",
				"/<u[^>]*?>([\w\W]*?)<\/u>/i" => "$1",
				
				// 标签头
				/*"/<br[^>]*?>/i" => "",*/
				"/<table[^>]*?>/i" => "",
				"/<tr[^>]*?>/i" => "",
				"/<td[^>]*?>/i" => "",
				/*"/<p[^>]*?>/i" => "",*/
				"/<font[^>]*?>/i" => "",
				"/<div[^>]*?>/i" => "",
				"/<span[^>]*?>/i" => "",
				"/<tbody[^>]*?>/i" => "",
				"/<([\/]?)b>/i" => "",
				/*"/<img[^>]*?>/i" => "",*/
				/*"/[&nbsp;]{2,}/i" => "",*/
				"/<script[^>]*?>/i" => "",
				
				
				//  ++++++++ 后来补充
				"/<input[^>]*?>/i" => "",
				
				// 标签尾
				"/<\/a>/i" => "",
				/*"/<\/br>/i" => "",*/
				"/<\/table>/i" => "",
				"/<\/tr>/i" => "",
				"/<\/td>/i" => "",
				//"/<\/p>/i" => "",
				"/<\/font>/i" => "",
				"/<\/div>/i" => "",
				"/<\/span>/i" => "",
				"/<\/tbody>/i" => "",
				"/<\/b>/i" => "",
				/*"/<img[^>]*?>/i" => "",*/
				/*"/[&nbsp;]{2,}/i" => "",*/
				"/<\/script>/i" => "",
				
			);
			foreach($pregs as $k=>$v){
				$content = preg_replace($k,$v,$content);
			}
			return $content;
		}
	
		/*
			随机产生一个不重复的文件名
			author $aming
			返回 string 文件名
			echo rand_file_name();
		*/
	
		function rand_file_name(){
			$names = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
					   'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
					   '0','1','2','3','4','5','6','7','8','9');
		
		
			 // PHP数组是从0开始排列的，所以这里要减一	
			 $c = count($names)-1;
			 
			 // 随机时间戳 <加密后的时间戳，从后往前截取5个数>
			 $t = substr(md5(time()),-5,5);
			
			// 随机组合10个不重复名称 
			return 'id_'.$names[rand(0,$c)].$names[rand(0,$c)].$names[rand(0,$c)].$names[rand(0,$c)].$names[rand(0,$c)].$t; 
		}
	}
	
	// 使用演示
	//$regular = new regular();
//	echo $regular->original('aaaaaaaaaaaaaaaaaaaaaaaaaaaa');
?>